package com.xiyili.topspecialty;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebSettings;
import android.webkit.WebView;

/**
 * Created by banxi1988 on 13-8-7.
 */
public class BaseWebappActivity extends BaseFragmentActivity {

    private String _res_url;
    private WebView _webView;

    @Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        Intent intent = getIntent();
        _res_url = intent.getStringExtra("res_url");

        setContentView(getLayoutResID());
        initViews();

    }

    private void initViews() {
        _webView = (WebView) findViewById(R.id.webview);
        // setttings
        WebSettings webSettings = _webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        _webView.loadUrl(_res_url);


    }

    protected int getLayoutResID() {
        return R.layout.activity_base_webapp;
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK) && _webView.canGoBack()) {
            _webView.goBack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }


}
